#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int b,k=0;
	cin>>s>>b;
	int t1=(s[0]-'0')/b;
	int t2=(s[0]-'0')%b;
	if(s.size()==1) {
		cout<<t1<<" "<<t2;
		return 0;
	}
	if(t1) cout<<t1;
	k+=t2;
	for(int i=1; i<s.size(); i++) {
		k=k*10+s[i]-'0';
		t1=k/b,t2=k%b;
		k=t2;
		cout<<t1;
	}
	cout<<" "<<t2;
	return 0;
}
